home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / internet misc / XML PalmPilot applications 1.0 / XTPP-latest.exe / Pilot / send.xst < prev   
Encoding:
Text File  |  1999-12-01  |  5.3 KB  |  245 lines

  1. <XST Filename='send.xst'
  2.      Description='Send an AddressRecord from the Pilot database to someone.'
  3.      Author='David Ball'
  4.      Version='2.0'
  5.      Date='8 April 1999'
  6.      Copyright='&copy; 1999 DecisionSoft Limited'
  7.      XMLscript='1.0'
  8.      Ref='send'
  9.      debug=''
  10.      __maxCR="2"
  11. ><_if test=" \ENV\REQUEST_METHOD.__exists" >Content-type: text/html
  12.  
  13. </_if>
  14.  
  15. <!--
  16.     We need the "Content-type: text/html" to be on the first output 
  17.     line followed by two carriage returns, if we're running in cgi
  18.  
  19.     Note the 'double backslash' used instead of the single backslash.  Always 
  20.     use double backslash when describing DOS/Windows directory paths.
  21. -->
  22.  
  23. <!--
  24.     YOU NEED TO CONFIGURE THESE
  25. -->
  26.     # $\.appsRoot := "..\\pilot\\" #
  27.     # $\.datName := "sample.dat" #
  28.  
  29. <!--
  30.     If we're coming in from the command line, arguments with spaces in 
  31.     will have quotes around them, which we don't want (because DOS batch 
  32.     files are lame).  So we need to get rid of them... 
  33. -->
  34.  
  35. <_if test="\ENV\FIRSTNAME.__exists">
  36.     <then>
  37.     <barney __mode="hide">
  38.     <fred __maxCR="0"><_filter find='\"' replace=''># \ENV\FIRSTNAME #</_filter></fred>
  39.     </barney>
  40.     # \ENV\FIRSTNAME := $barney\fred #
  41.     </then>
  42. </_if>
  43.  
  44.  
  45. <!--
  46.     Set up our hostname 
  47. -->
  48.  
  49. <_if test=" \CGI\hostname.__exists">
  50. <then> # $\.hostname := \CGI\hostname # </then>
  51. <else>
  52.     <_if test="\ENV\HOSTNAME.__exists">
  53.     <then> # $\.hostname := \ENV\HOSTNAME # </then>
  54.     <else>
  55.         <_if test="\ENV\COMPUTERNAME.__exists">
  56.         <then> # $\.hostname := \ENV\COMPUTERNAME # </then>    
  57.         <else>
  58.             <_if test="\ENV\USERDOMAIN.__exists">
  59.             <then> # $\.hostname := \ENV\USERDOMAIN # </then>
  60.             <else> # $\.hostname := "localhost" # </else>
  61.             </_if>
  62.         </else>
  63.         </_if>
  64.     </else>
  65.     </_if>
  66. </else>
  67. </_if>
  68.  
  69. # $.sn := "0" #
  70. # $.fn := "0" #
  71.  
  72. <_if test="not(\CGI\surname.__exists) and ( \ENV\SURNAME.__exists)" >
  73.     # \CGI\surname := \ENV\SURNAME #
  74. </_if>
  75.  
  76. <_if test="not(\CGI\firstname.__exists) and ( \ENV\FIRSTNAME.__exists)" >
  77.     # \CGI\firstname := \ENV\FIRSTNAME #
  78. </_if>
  79.  
  80. <_if test="not(\CGI\email.__exists) and ( \ENV\EMAIL.__exists)" >
  81.     # \CGI\email := \ENV\EMAIL #
  82. </_if>
  83.  
  84. <_if test="not(\CGI\mailserver.__exists) and ( \ENV\MAILSERVER.__exists)" >
  85.     # \CGI\mailserver := \ENV\MAILSERVER #
  86. </_if>
  87.  
  88. <_if test="not(\CGI\rcpt.__exists) and ( \ENV\RCPT.__exists)" >
  89.     # \CGI\rcpt := \ENV\RCPT #
  90. </_if>
  91.  
  92. <_if test=" \ENV\REQUEST_METHOD.__exists" >
  93.     <then> # $\.context := "cgi" # </then>
  94.     <else> # $\.context := "cmdline" # </else>
  95. </_if>
  96.  
  97. <_if test="\CGI\surname.__exists"># $.sn := 1 #</_if>
  98. <_if test="\CGI\firstname.__exists"># $.fn := 1 #</_if>
  99.  
  100. <_if>
  101.  
  102. <!--
  103.     Defaults used for debugging
  104. -->
  105.         # \CGI\rcpt := "support@xmlscript.org" #
  106.         # \CGI\mailserver := "mail1.best.com" #
  107.         # \CGI\firstname := "William" #  # $.fn := 1 #
  108.         # \CGI\surname := "Clinton" #  # $.sn := 1 #
  109.         # \CGI\email := "test-send@xmlscript.org" #
  110. </_if>
  111.  
  112. <!--
  113.     Define the system command
  114. -->
  115.  
  116. # $\.cmd := $\.appsRoot 'loadbook ' $\.appsRoot $\.datName #
  117. # $\.sysCmd := $\.cmd '>  c:\\temp\\CGItmp.txt' #
  118.  
  119.  
  120. <!--
  121.     The system command is piped to file to make it work with httpd. 
  122. -->
  123.  
  124. <_eval result="data">
  125. <_filter find='\#' replace='' >
  126.     <Pilot>
  127.         <_system command="# $\.sysCmd #"/>
  128.         <_echo file="c:\temp\CGItmp.txt" />
  129.     </Pilot>
  130. </_filter>
  131. </_eval>
  132.  
  133. <_if test="0">
  134.     Debug information: incoming data -# \Pilot #-
  135. </_if>
  136.  
  137.  
  138.  
  139. <!--
  140.     Define the template we're going to run 
  141. -->
  142.  
  143. <_template name="SendMail">
  144.  
  145. <_socket host="# \CGI\mailserver #" port="25" store="irrel" timeout="180">
  146.  
  147. <read_to>
  148. </read_to>
  149. <write>HELO # $\.hostname #
  150. </write>
  151. <read_to>
  152. </read_to>
  153. <write>MAIL FROM: # \CGI\email #
  154. </write>
  155. <read_to>
  156. </read_to>
  157. <write>RCPT TO: # \CGI\rcpt #
  158. </write>
  159. <read_to>
  160. </read_to>
  161. <write>DATA
  162. </write>
  163. <read_to>
  164. </read_to>
  165. <write>From: # \CGI\email #
  166. To: # \CGI\rcpt #
  167. Subject: XML AddressRecord for # \CGI\firstname # # \CGI\surname #.
  168.  
  169. <_foreach object="AddressRecord" __maxCR="2">
  170. <_if test="not($.sn)"># \CGI\surname := LastName #</_if>
  171. <_if test="not($.fn)"># \CGI\firstname := FirstName #</_if>
  172. <_if test="(LastName == \CGI\surname) and (FirstName == \CGI\firstname)">
  173. <then>
  174. # .__object #
  175.  
  176. </then>
  177. </_if>
  178. </_foreach>
  179. .
  180. </write>
  181. <read_to>
  182. </read_to>
  183. <write>QUIT
  184. </write>
  185. <close />
  186.  
  187. </_socket>
  188.  
  189. <!-- 
  190.     This is not foolproof, but it is a quick look to see 
  191.     if we succeeded in sending the mail
  192. -->
  193.  
  194. <_if test="(irrel\data[3] == '')">
  195.     <then># $\.msg := 'X-Tract: connection timed out.'#</then>
  196.     <else># $\.msg := 'X-Tract: mail sent successfully.'#</else>
  197. </_if>
  198.  
  199. <_if test="$.context == cgi">
  200.     <then>
  201.         <HTML>
  202.         <HEAD><TITLE>Xtract Mail Report</TITLE></HEAD>
  203.         <BODY BGCOLOR="ffffff">
  204.         <H1 ALIGN="Left"># $.msg #</H1>
  205.         </BODY>
  206.         </HTML>
  207.     </then>
  208.     <else># $.msg #</else>
  209. </_if>
  210.  
  211. </_template>
  212.  
  213. <!--
  214.     Tie the template to the data
  215. -->
  216.  
  217. <_method object="Pilot" template="SendMail" />
  218.  
  219. <!--
  220.     Process the data
  221. -->
  222.  
  223. <_if test="(\CGI\rcpt.__exists) and (\CGI\email.__exists) and (\CGI\mailserver.__exists)">
  224.     <then>
  225.         <_process object="\Pilot" />
  226.     </then>
  227.     <else>
  228.         <_if test="$.context == cgi">
  229.             <then>
  230.                 <HTML>
  231.                 <HEAD><TITLE>Xtract Mail Report</TITLE></HEAD>
  232.                 <BODY BGCOLOR="ffffff">
  233.                 <H1 ALIGN="Left">X-Tract: mail not Sent.</H1>
  234.                 </BODY>
  235.                 </HTML>
  236.             </then>
  237.             <else>
  238. X-Tract: mail not Sent.
  239.             </else>
  240.         </_if>
  241.     </else>
  242. </_if>
  243.  
  244. </XST>
  245.